﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace WpfDemo.Converter
{
    public class StrToEnableConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null) return "启用";
            if(value.ToString()=="1") return "禁用";
            else return "启用";           
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if(value==null) return "0";
            var temp = value.ToString();
            if (temp == "禁用") return "1";
            else return "0";            
        }
    }
}
